package com.zjj.day0425.regex;

/**
 * @author zhoujunjie
 * @desc TODO
 * @date 2025/4/25
 */
import java.util.Scanner;
import java.util.regex.Pattern;

public class UsernameValidatorRegex {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入要校验的用户名:");
        String username = scanner.nextLine();
        scanner.close();

        if (isValidUsername(username)) {
            System.out.println("输入的用户名合法。");
        } else {
            System.out.println("输入的用户名不合法。");
        }
    }

    public static boolean isValidUsername(String username) {
        String regex = "^[a-zA-Z][a-zA-Z0-9_]{5,11}$";
        return Pattern.matches(regex, username);
    }
}